<?php

namespace App\Console\Commands;

use App\Model\Order;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

class OrderTimeoutCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'order:timeout';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '订单超时失败';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        Order::query()->where('updated_at', '<', now()->subMinutes(5)->toDateTimeString())
            ->where('recharge_status', 1)->where('status', 3)->update([
                'recharge_status' => 2,
            ]);
    }
}
